package com.zhuoyian.analysis.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;


public class EncodeUtil {

	/**
	 * 编码
	 * @param str
	 * @return
	 */
	public static String encodeUTF8(String str) {
		try {
			return URLEncoder.encode(str, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return str;
	}
	
	/**
	 * 解码
	 * @param str
	 * @return
	 */
	public static String decoderUTF8(String str) {
	
		try {
			return URLDecoder.decode(str, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return str;
	}

}
